package com.hyacinth.lotterysystem.common.config;

import com.hyacinth.lotterysystem.common.interceptor.LoginInterceptor;
import jakarta.annotation.Resource;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.util.Arrays;
import java.util.List;

@Configuration
public class WebConfig implements WebMvcConfigurer {
    @Resource
    private LoginInterceptor loginInterceptor;

    private final List<String> excludes = Arrays.asList(
            "/user/password/login",
            "/user/email/login",
            "/user/register"
    );

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loginInterceptor)
                .addPathPatterns("/user/**")
                .addPathPatterns("/prize/**")
                .addPathPatterns("/activity/**")
                .excludePathPatterns(excludes);
    }
}
